<template>
    <div>
        <h1>父组件</h1>
        <button @click="changeShow">改变show的值</button>
        <Son v-if="show"></Son>
    </div>
</template>

<script lang="ts">
import {
    defineComponent, onBeforeMount,
    onBeforeUnmount,
    onBeforeUpdate,
    onMounted,
    onUnmounted,
    onUpdated,
    ref,
} from 'vue'
import Son from "./Son.vue"

export default defineComponent({
    components: {
        Son,
    },
    setup() {
        let show = ref(true);
        function changeShow() {
            console.log(show);
            //时时刻刻注意 vue3当中处理ref的值的时候需要 xx.vue
            show.value = !show.value;
        }
        onBeforeMount(() => {
            console.log("父组件的onBeforeMount");
        });
        onMounted(() => {
            console.log("父组件的onMounted");
        });
        onBeforeUpdate(() => {
            console.log("父组件的onbeforeUpadte");
        });
        onUpdated(() => {
            console.log("父组件的onUpdated");
        });
        onBeforeUnmount(() => {
            console.log("父组件的onBeforeUnmount");
        });
        onUnmounted(() => {
            console.log("父组件onUnmounted");
        });
        return {
            show,
            changeShow,
        };
    },
    beforeCreate() {
        console.log("父组件的beforeCreate");
    },
    created() {
        console.log("父组件的created");
    },
    beforeMount() {
        console.log("父组件的beforeMount");
    },
    mounted() {
        console.log("父组件的mounted");
    },
    beforeUpdate() {
        console.log("父组件的beforeUpdate");
    },
    updated() {
        console.log("父组件的updated");
    },
    beforeUnmount() {
        console.log("父组件的beforeUnmount");
    },
    unmounted() {
        console.log("父组件的unmounted");
    },
});
</script>

<style scoped>

</style>